package ren.yugong.fileutil;

import java.io.*;

public class TxtTemplateLengthReadStream<T> implements TxtReadStream<T> {

    private TxtTemplateModel templateModel;
    private InputStreamReader reader;

    protected TxtTemplateLengthReadStream(TxtTemplateModel templateModel) {
        this.templateModel = templateModel;
    }

    @Override
    public void open(File file) {
        String charset = templateModel.getCharset();
        try {
            reader = new InputStreamReader(new FileInputStream(file), charset);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
    }

    @Override
    public T read() {
        return null;
    }

    @Override
    public void close() {
        try {
            if (null != reader) reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
